@echo off

if not exist "D:\mysql_bak" md "D:\mysql_bak"
set host=127.0.0.1
set port=3306
set user=root
set pass=root 
 
set dbname=mannagement

set hour=%time:~0,2%
if "%time:~0,1%"==" " set hour=0%time:~1,1%
 
set backup_date=%Date:~0,4%%Date:~5,2%%Date:~8,2%%hour%%Time:~3,2%%Time:~6,2%
 
//****
"C:\Program Files\MySQL\MySQL Server 8.0\bin\mysqldump"  -h%host% -P%port% -u%user% -p%pass% -c --add-drop-table %dbname% > D:\mysql_bak\%dackup_date%_mannagement.sql

forfiles /p C:\mysql_bak /s /m *.sql /d -7 /c "cmd /c del @file /f"

mysql -uroot -proot mannagement < src/main/resources/date.sql

pause
